-
-
Notifications
You must be signed in to change notification settings - Fork 478
refactor: remove getTriggerDOMNode usage #1149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough本次更改主要重构了 BaseSelect、SelectTrigger 和 Selector 组件中的 DOM 引用管理方式。移除了 selectorDomRef 和相关 domRef/getTriggerDOMNode 属性,统一用 customDomRef 和 selectorRef 管理 DOM。Selector 组件的 ref 接口增加了 nativeElement 属性,方便直接访问容器元素。 Changes
Sequence Diagram(s)sequenceDiagram
participant Parent
participant BaseSelect
participant Selector
participant SelectTrigger
Parent->>BaseSelect: 使用 ref 获取 nativeElement
BaseSelect->>Selector: 传递 ref
Selector->>BaseSelect: 暴露 nativeElement (containerRef)
BaseSelect->>Parent: 返回 nativeElement
Note over BaseSelect,Selector: 不再传递 domRef/getTriggerDOMNode,统一 ref 管理
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/BaseSelect/index.tsxOops! Something went wrong! :( ESLint: 8.57.1 Error: Cannot read config file: /.eslintrc.js
src/Selector/index.tsxOops! Something went wrong! :( ESLint: 8.57.1 Error: Cannot read config file: /.eslintrc.js
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
🔇 Additional comments (8)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
最终有多少提升,可以在发到 antd 的 PR 中做一个 benchmark 写一下。 |
OK 清理完后搞个,不过如 description 里写的,这只会对 dev 有体验优化。 |
背景
在 ant-design/ant-design#50443 中提到 Tooltip 的渲染性能问题,经过排查在 dev 模式下性能主要损耗在于
ReactElement
创建上(prop 模式下不开启 react dev tool 其实并没有那么卡)。不过开发者的体验也是有提升空间的。为什么改 Select?
rc-trigger
有一个特殊方法getTriggerDOMNode
允许自定义寻找 DOM 节点的逻辑而不是直接 ref 获取子元素。这对于 HOC 后提供的 ref 不是 DOM 的情况很有帮助,而在新的 ref 规范中,我们认为ref.nativeElement
可以标识 DOM 节点。因而可以借此减少getTriggerDOMNode
的调用,从而最终清理后在上述 issue 中减少createElement
的数量。Summary by CodeRabbit